package com.unicorn.auth.domain;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

public class UserValidator implements Validator {
	@Override
	public boolean supports(Class candidate) {
		return User.class.isAssignableFrom(candidate);
	}

	@Override
	public void validate(Object obj, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "loginName",
				"required", "Field is required.");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password",
				"required", "Field is required.");
	}

}